package com.briup.day17;

import java.util.ArrayList;
import java.util.Collection;

public class Generics {
    public static void main(String[] args) {
        //实例化泛型类对象
        Circle<Integer,Double> c=new Circle<>(1,1,2.5);
        c.disp(10);//可以传任意类型
        Circle.show(10);
        Circle.show("hello");
    }
    public static void main03(String[] args) {
        IAction<String> ic = new IActionImpl<>();
        ic.show();
     }
    public static void main02(String[] args) {
        Circle<Integer,Double> c1=new Circle<>(1,2,2.3);
        Circle<Double,Double> c2=new Circle<>(2.1,2.2,2.3);
        Integer x= c1.getX();
        Double radius=c1.getRadius();
        System.out.println(x+","+radius);
        System.out.println(c1);
        System.out.println(c2);
    }
    public static void main01(String[] args) {
        Collection c = new ArrayList();
        c.add("hello1");
        c.add("hello2");
        c.add(2.3f);
        c.add(1);
        for(Object o:c){
            String s = (String) o;
            System.out.println(o);
        }
    }
}
class Circle<T,E>{
    private T X;
    private T Y;
    private E radius;
    public Circle(T X, T Y, E radius) {
        this.X = X;
        this.Y = Y;
        this.radius = radius;
    }

    public T getX() {
        return X;
    }

    public void setX(T x) {
        X = x;
    }

    public T getY() {
        return Y;
    }

    public void setY(T y) {
        Y = y;
    }

    public E getRadius() {
        return radius;
    }

    public void setRadius(E radius) {
        this.radius = radius;
    }

    @Override
    public String toString() {
        return "Circle{" +
                "X=" + X +
                ", Y=" + Y +
                ", radius=" + radius +
                '}';
    }
    public <F> void disp(F f){
        System.out.println("in disp"+f);
    }
    public static <F> void show(F f){
        System.out.println("in disp"+f);
    }
}
interface IAction<T>{
    T show();
}
class IActionImpl<T> implements IAction<T>{
    private T a;
    public  T show() {

        System.out.println("show");
        return a;
    }
}